package com.alex.space;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

/**
 * @author Alex
 * Created by Alex on 2018/4/9.
 */
@Service
public class HelloService {

	@Autowired
	RestTemplate restTemplate;

	@HystrixCommand(fallbackMethod = "helloError")
	public String hello(String name) {
		return restTemplate.getForObject("http://SERVICE-HELLO/hello?name=" + name, String.class);
	}

	public String helloError(String name) {
		return "hi," + name + ",sorry,error!";
	}

}
